﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Administrator_replyemail : System.Web.UI.Page
{
    private AskController objAsk = new AskController();
    private MailController objMail = new MailController();
    public static string id = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetData();
        }
    }

    private void GetData()
    {
        try
        {
            id = Int32.Parse(Request.QueryString["id"].ToString()).ToString();
            DataTable dtAsk = objAsk.GetByID(id);
            txtEmail.Text = dtAsk.Rows[0]["EMAIL"].ToString();
            txtName.Text = dtAsk.Rows[0]["FULLNAME"].ToString();
            txtPhone.Text = dtAsk.Rows[0]["PHONE"].ToString();
            txtAddress.Text = dtAsk.Rows[0]["ADDRESS"].ToString();
        }
        catch
        {
        }
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string email = txtEmail.Text.Trim();
        string content = txtContent.Text.Trim();
        bool kt = objMail.SendMail(email, "Hẹn tốc độ", content);
        if (kt == true)
        {
            objAsk.UpdateMailStatus(id);
            string str = "<script type='text/javascript'>";
            str += "function OnRemove(){self.parent.tb_remove();}OnRemove();";
            str += "</script>";
            Response.Write(str);
        }
    }
}